package csm.web.service.search;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.context.Context;

import csm.web.core.RequestHelper;
import csm.web.core.TemplateServletBase;
import csm.web.core.search.MashupItemList;
import csm.web.core.search.SearchFacade;
import csm.web.core.search.SearchResultInfo;

public class SearchServiceServlet extends TemplateServletBase{

	/**	 */
	private static final long serialVersionUID = -4903824645705278775L;

	@Override
	public void populate(HttpServletRequest request, HttpServletResponse response, Context context) throws Exception {
		String viewPage = getPathInfo().getViewPage();
		context.put("PAGE", getThemaName(request) + "/" + viewPage);

		RequestHelper req = new RequestHelper(request);

		// mash-up 목록 : 이 목록은 Front-end단으로 전달되어 ajax 처리될 기회를 제공한다.
		context.put("MASHUP_LIST", MashupItemList.getInstance().getItems());

		SearchResultInfo resultSet = SearchFacade.doIRSearch(req);

		// 검색결과 목록
		context.put("SEARCH_RESULT_SET", resultSet);
	}
}
